load("@rules_cc//cc:defs.bzl", "cc_library")

exports_files(
    ["crypt.h.in"],
    visibility = ["//:__pkg__"],
)

cc_library(
    name = "crypt",
    srcs = [
        "alg-des.c",
        "alg-des.h",
        "alg-des-tables.c",
        "alg-gost3411-2012-const.h",
        "alg-gost3411-2012-core.c",
        "alg-gost3411-2012-core.h",
        "alg-gost3411-2012-hmac.c",
        "alg-gost3411-2012-hmac.h",
        "alg-gost3411-2012-precalc.h",
        "alg-gost3411-2012-ref.h",
        "alg-hmac-sha1.c",
        "alg-hmac-sha1.h",
        "alg-md4.c",
        "alg-md4.h",
        "alg-md5.c",
        "alg-md5.h",
        "alg-sha1.c",
        "alg-sha1.h",
        "alg-sha256.c",
        "alg-sha256.h",
        "alg-sha512.c",
        "alg-sha512.h",
        "alg-yescrypt.h",
        "alg-yescrypt-common.c",
        "alg-yescrypt-opt.c",
        "byteorder.h",
        "crypt.c",
        "crypt-bcrypt.c",
        "crypt-des.c",
        "crypt-gensalt-static.c",
        "crypt-gost-yescrypt.c",
        "crypt-md5.c",
        "crypt-nthash.c",
        "crypt-pbkdf1-sha1.c",
        "crypt-port.h",
        "crypt-scrypt.c",
        "crypt-sha256.c",
        "crypt-sha512.c",
        "crypt-static.c",
        "crypt-sunmd5.c",
        "crypt-yescrypt.c",
        "util-base64.c",
        "util-gensalt-sha.c",
        "util-get-random-bytes.c",
        "util-make-failure-token.c",
        "util-xbzero.c",
        "util-xstrcpy.c",
        "//:config.h",
        "//:crypt-hashes.h",
        "//:crypt-symbol-vers.h",
    ],
    hdrs = [
        "//:crypt.h",
    ],
    local_defines = [
        "HAVE_CONFIG_H",
        "IN_LIBCRYPT",
    ],
    textual_hdrs = [
        "alg-yescrypt-platform.c",
    ],
)

alias(
    name = "lib",
    actual = ":crypt",
    visibility = ["//:__pkg__"],
)

cc_library(
    name = "test",
    testonly = True,
    srcs = [
        "alg-des.c",
        "alg-des-tables.c",
        "alg-gost3411-2012-core.c",
        "alg-gost3411-2012-hmac.c",
        "alg-hmac-sha1.c",
        "alg-md4.c",
        "alg-md5.c",
        "alg-sha1.c",
        "alg-sha256.c",
        "alg-sha512.c",
        "alg-yescrypt-common.c",
        "alg-yescrypt-opt.c",
        "crypt.c",
        "crypt-bcrypt.c",
        "crypt-des.c",
        "crypt-gensalt-static.c",
        "crypt-gost-yescrypt.c",
        "crypt-md5.c",
        "crypt-nthash.c",
        "crypt-pbkdf1-sha1.c",
        "crypt-scrypt.c",
        "crypt-sha256.c",
        "crypt-sha512.c",
        "crypt-static.c",
        "crypt-sunmd5.c",
        "crypt-yescrypt.c",
        "util-base64.c",
        "util-gensalt-sha.c",
        "util-get-random-bytes.c",
        "util-make-failure-token.c",
        "util-xbzero.c",
        "util-xstrcpy.c",
    ],
    hdrs = [
        "alg-des.h",
        "alg-gost3411-2012-const.h",
        "alg-gost3411-2012-core.h",
        "alg-gost3411-2012-hmac.h",
        "alg-gost3411-2012-precalc.h",
        "alg-gost3411-2012-ref.h",
        "alg-hmac-sha1.h",
        "alg-md4.h",
        "alg-md5.h",
        "alg-sha1.h",
        "alg-sha256.h",
        "alg-sha512.h",
        "alg-yescrypt.h",
        "byteorder.h",
        "crypt-port.h",
        "//:config.h",
        "//:crypt.h",
        "//:crypt-hashes.h",
        "//:crypt-symbol-vers.h",
    ],
    defines = [
        "HAVE_CONFIG_H",
    ],
    local_defines = [
        "IN_LIBCRYPT",
    ],
    textual_hdrs = [
        "alg-yescrypt-platform.c",
    ],
    visibility = ["//test:__pkg__"],
)
